﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.ComponentModel;
using ChessAnotator.UserControls;
using ChessAnotator.Base.Business;

namespace ChessAnotator
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Main : Window, INotifyPropertyChanged
    {
        #region INotifyPropertyChanged Members
        public event PropertyChangedEventHandler PropertyChanged;

        private void NotifyPropertyChanged(String propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
        #endregion

        #region Properties
        int m_nSquareSize;
        public int SquareSize2
        {
            get
            {
                return m_nSquareSize;
            }
            set
            {
                m_nSquareSize = value;
                NotifyPropertyChanged("SquareSize2");
            }
        }

        public double PieceScale
        {
            get;
            set;
        }

        private double m_nOverlayOpacity;
        public double OverlayOpacity
        {
            get
            {
                return m_nOverlayOpacity;
            }
            set
            {
                m_nOverlayOpacity = value;
                NotifyPropertyChanged("OverlayOpacity");
            }
        }
        #endregion

        public Main()
        {
            //this.SquareSize = 80;
            //this.PieceScale = 0.11;
            //this.OverlayOpacity = 0.5;

            InitializeComponent();

            this.LayoutRoot.DataContext = this;

            //sqC8.SquareBackground = new SolidColorBrush(Colors.LightGray);

            //BlackRook rook = new BlackRook();
            //rook.Scale = 0.16;
            ////sqA8Control.Content = rook;
            //sqC8.SetPiece(rook);
            //sqC8.SetSquareAttackersCount(21, 10);

            //sqC8.SetSquareSize(this.SquareSize);

        //    InitializeBoard();

          //  ChessBoard.SquareSize = 80;
          //  ChessBoard.InitializeBoard();

//            ChessBoard.LoadPosition("rnbqkbnr/pp1ppppp/8/2p5/4P3/5N2/PPPP1PPP/RNBQKB1R b KQkq - 1 2");
          //  ChessBoard.LoadPosition("r1bq4/1p4kp/3p1n2/p4pB1/2pQ4/8/1P4PP/4RRK1 b KQkq - 1 2");
            ChessBoard.LoadPosition("r1b3k1/1p3q1p/3p1Q1B/p4p2/2p5/8/1P4PP/5RK1 b KQkq - 1 2");
        }

        private void cmdTest_Click(object sender, RoutedEventArgs e)
        {
            this.SquareSize2 = 80;

           // ChessBoard.SquareSize = 80;
            ChessBoard.OverlayOpacity = 1;

            this.OverlayOpacity = 1;
            //sq02.BlackAttackersCount = 5;
            //sq02.WhiteAttackersCount = 12;

            Square oCurrSquare = (Square)LogicalTreeHelper.FindLogicalNode(this, "sq03");
            oCurrSquare.BlackAttackersCount = 5;
            oCurrSquare.WhiteAttackersCount = 12;

            //ChessBoard.LoadPosition("rnbqkbnr/pp1ppppp/8/2p5/4P3/5N2/PPPP1PPP/RNBQKB1R b KQkq - 1 2");
            ChessBoard.LoadPosition("rnbqkbnr/pp2pppp/8/2pp4/4P3/5N2/PPPP1PPP/RNBQKB1R b KQkq - 1 2");
        }
    }
}
